<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <meta
      name="description"
      content="汇融名企是面向全国商家服务的大型互联网平台，为商家提供流量扶持，引导品牌曝光；为消费者提供风云榜单，招商加盟，引导实现消费，达成合作，上汇融名企实现共赢。"
    />
    <title>招标详情-汇融名企</title>
    <link rel="stylesheet" href="./css/common.css" />
    <link rel="stylesheet" href="./css/tenderDetails.css" />
  </head>

  <body>
    <!-- <div id="header-page"></div> -->
    <!--#include virtual="/header.html" -->
    <!-- 内容 -->
    <div class="tenderDetails-content">
      <div class="tenderDetails-content-left">
        <div
          class="tenderDetails-left-title need-text-overflow"
          id="entry_name"
        >
          甘肃甜永路面3标
        </div>
        <div class="tenderDetails-left-message">
          <div class="tenderDetails-text" id="cont_dtl"></div>
          <div class="tenderDetails-left-border"></div>
          <div class="tenderDetails-recommend-title">
            <h3>
              <span>※</span>
              <span>为你推荐</span>
            </h3>
          </div>
          <div class="recommend-you"></div>
        </div>
      </div>
      <div class="tenderDetails-content-right">
        <div class="tenderDetails-right-top">
          <div class="tenderDetails-right-top-title">
            <div class="tenderDetails-right-text">热门招标</div>
            <div class="tenderDetails-right-more">
              <a href="tenderingList.html">
                <span>更多</span>
                <span>></span>
              </a>
            </div>
          </div>
          <div class="tenderDetails-right-list-box"></div>
        </div>
        <div class="tenderDetails-right-bottom">
          <div class="tenderDetails-right-up">
            <img src="./image/icon/home_htn_jiantou.png" />
          </div>
          <div class="tenderDetails-right-content">
            <ul
              class="tenderDetails-right-nav"
              id="tenderDetails-right-nav"
            ></ul>
          </div>
          <div class="tenderDetails-right-down">
            <img src="./image/icon/home_htn_jiantou02.png" />
          </div>
        </div>
      </div>
    </div>
    <!-- <div id="footer-page"></div> -->
    <!--#include virtual="/footer.html" -->
    <script src="./js/jquery-1.11.0.min.js"></script>
    <script src="./js/utils.js"></script>
    <script src="./js/api.js"></script>
    <script src="./js/homeImages.js"></script>
    <script>
      $(function () {
        // $('#header-page').load('header.html')
        // $('#footer-page').load('footer.html')
        // 获取接口
        var params = getURLParams()
        var api = new ajax('GET', '/api/tendInfo/details?tend_id=' + params.id)
        api.then(function (res) {
          init(JSON.parse(res).data)
        })
        // 右侧纵向滚动展示
        // 赋值
        initSliderItem(sliderItemData, $('#tenderDetails-right-nav'))
        var topTimer = ''
        $('.tenderDetails-right-down').click(function (e) {
          e.preventDefault()
          if (!topTimer) {
            var top = $('#tenderDetails-right-nav').css('top').split('px')[0]
            top -= 170
            topTimer = $('#tenderDetails-right-nav').animate(
              {
                top: top + 'px',
              },
              500,
              function () {
                topTimer = ''
                var el = $('#tenderDetails-right-nav').children().eq(0).html()
                $('#tenderDetails-right-nav').append('<li>' + el + '</li>')
                $('#tenderDetails-right-nav').children().eq(0).remove()
                $('#tenderDetails-right-nav').css('top', 0)
              }
            )
          }
        })
        var rightTimer = ''
        $('.tenderDetails-right-up').click(function () {
          if (!rightTimer) {
            var last = $('#tenderDetails-right-nav').children().length - 1
            var el = $('#tenderDetails-right-nav').children().eq(last).html()
            $('#tenderDetails-right-nav').prepend('<li>' + el + '</li>')
            $('#tenderDetails-right-nav').css('top', '-170px')
            rightTimer = $('#tenderDetails-right-nav').animate(
              {
                top: 0 + 'px',
              },
              500,
              function () {
                rightTimer = ''
                $('#tenderDetails-right-nav')
                  .children()
                  .eq(last + 1)
                  .remove()
              }
            )
          }
        })
      })
      // 数据获取
      function init(data) {
        var tendInfoItem = data.tendInfo
        var hotTenderItem = data.hotTender
        var recommendItem = data.recommend
        document.title = tendInfoItem.entry_name + '-汇融名企'
        initHotTenderItem(hotTenderItem, $('.tenderDetails-right-list-box'))
        initRecommendItem(recommendItem, $('.recommend-you'))
        //初始化信息
        for (key in tendInfoItem) {
          $('#' + key).html(tendInfoItem[key])
        }
      }
      function initHotTenderItem(data, parent) {
        var el = ''
        for (key in data) {
          var currentData = data[key]
          var temp = [
            '<div class="tenderDetails-right-list" id="tenderDetails-right-' +
              currentData.tend_id +
              '">' +
              '<a href="tenderDetails.html?id=' +
              currentData.tend_id +
              '">' +
              '<span>' +
              currentData.entry_name +
              '</span>' +
              '<span>' +
              getDate(data[key].release_time, 3) +
              '</span>' +
              '</a>' +
              '</div>',
          ].join('')
          el += temp
        }
        parent.append(el)
      }
      function initRecommendItem(data, parent) {
        var el = ''
        for (key in data) {
          var currentData = data[key]
          var temp = [
            '<div class="recommend-you-content" id="recommand-item-' +
              currentData.tend_id +
              '">' +
              '<p>' +
              currentData.entry_name +
              '</p>' +
              '</div>',
          ].join('')
          el += temp
        }
        parent.append(el)
        $('.recommend-you-content').click(function (e) {
          var id = e.currentTarget.id.split('-')[2]
          go('tenderDetails.html?id=' + id)
        })
      }
      function initSliderItem(data, parent) {
        var item = ''
        for (var i in data) {
          var currentData = data[i]
          item +=
            '<li><a target="_blank" href="' +
            currentData.url +
            '"><img src="' +
            currentData.images +
            '"/></a></li>'
        }
        parent.append(item)
      }
    </script>
  </body>
</html>
